#ifndef __CMA_OPTIMIZER_H__
#define	__CMA_OPTIMIZER_H__

#include "Individual.h"
#include "Optimizer.h"
#include "Model.h"
#include "OptimizationSupervisor.h"
#include "CMA.h"
#include <vector>

namespace learn {

struct CMAOprimizer : Optimizer {
	enum CMAMode {
		RANK_MU_UPDATE = 1,
		RANK_ONE_UPDATE = 2,
		ONE_PLUS_ONE = 4,
	};
	
	CMAOprimizer();	
	virtual ~CMAOprimizer();
	
	virtual float optimize(Model &model, ErrorFunction &errorFunction, OptimizationSupervisor &data);	
	
	void init(Model &model, CMAMode cmaMode = RANK_MU_UPDATE, int lambda = -1, int mu = -1);
private:
	bool isFirstIteration;
	learn::CMA cma;
	CMAMode cmaMode;
	float bestFitness;
	std::vector<float> bestParameters;
	
	std::vector<float> parentParams;
	std::vector<float> offspringParams;
	std::vector<learn::Individual> parents;	
	std::vector<learn::Individual> offsprings;
};

}

#endif	/* __CMA_OPTIMIZER_H__ */

